﻿//CustomClass Template - Created by CodenameGamma
//Replace Layout with the CC name, 
//and WoWClass.Rogue with the Class your Designing for.
//Created July, 3rd 2010
//For use with Honorbuddy

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Text;
using System.IO;
using System.Drawing;
using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using TreeSharp;

namespace RaidMasterRogue
{
    class Classname : CombatRoutine
    {
        public override sealed string Name { get { return "Raid Master Rogue v0.01"; } }

        public override WoWClass Class { get { return WoWClass.Rogue; } }

        private static LocalPlayer Me { get { return ObjectManager.Me; } }

        public enum ClassType { None = 0, Assassination, Combat, Subtlety }
        public static ClassType ClassSpec { get; set; }
        //Logging.Write(Color.White, string.Format("You are a level {0} {1} {2}", Me.Level, ClassSpec, Me.Class));

        private WoWPlayer playerDD = null;
		private WoWPlayer lastPlayer = null;
		private WoWUnit enemy = null;

		private bool CheckUnit(WoWUnit unit)
        {
            return unit != null && unit.IsValid && unit.IsAlive;
        }
		private bool CheckMe(WoWUnit unit)
        {
            return unit != Me && unit != null && unit.IsValid && unit.IsAlive;
        }

		private List<WoWPlayer> GroupMembers { get { return ObjectManager.GetObjectsOfType<WoWPlayer>(true, true).ToList(); } }
        private WoWPlayer GetPlayer()
        {
            foreach (WoWPlayer player in GetGroupMembersInRange())
            {
                if (CheckUnit(player) && !IsTank(player) && !IsHealer(player) && CheckMe(player)) return player;
            }
            return null;
        }
        private string DeUnicodify(string spell)
        {
            StringBuilder sb = new StringBuilder();
            byte[] bytes = Encoding.UTF8.GetBytes(spell);

            foreach (byte b in bytes)
            {
                if (b != 0)
                    sb.Append("\\" + b);
            }

            return sb.ToString();
        }
        private bool IsTank(WoWPlayer player)
        {
            if (CheckUnit(player))
            {
                return Lua.GetReturnValues("return UnitGroupRolesAssigned('" + DeUnicodify(player.Name) + "')").First() == "TANK";
            }

            return false;
        }
        private bool IsHealer(WoWPlayer player)
        {
            if (CheckUnit(player))
            {
                return Lua.GetReturnValues("return UnitGroupRolesAssigned('" + DeUnicodify(player.Name) + "')").First() == "HEALER";
            }

            return false;
        }
		private IEnumerable<WoWPlayer> GetGroupMembersInRange()
        {
            return (from unit in GroupMembers
                    orderby unit.MaxHealth descending
                    where (unit.IsInMyPartyOrRaid || unit.IsMe)
                    where !unit.Dead
                    where !unit.IsGhost
                    where unit.Distance2D <= 90
                    where unit.InLineOfSight
                    select unit);
        }
		private void SelectPlayer()
		{
			if (!CheckPlayer())
			{
				playerDD = GetPlayer();
			}
			if (playerDD == lastPlayer)
			{
				playerDD = GetPlayer();
			}
		}
		private bool CheckPlayer()
		{
			if (playerDD != null && playerDD != Me)
			{
				return true;
			}
			return false;
		}
		private void ReTarget(WoWUnit target)
        {
            if (CheckUnit(Me) && CheckUnit(target))
            {
                target.Target();
            }
        }

        #region Log
        private void slog(string format, params object[] args) //use for slogging
        {
            Logging.Write(format, args);
        }
        #endregion

		#region SpecDetection
		public static class Talents
		{
			private enum ClassType
			{
				None = 0,
				Spec1,
				Spec2,
				Spec3
			}
    
			private static void LoadCurrentSpec() { Load(ActiveGroup); }

			private static readonly string[] TabNames = new string[4];
			private static readonly int[] TabPoints = new int[4];
			private static int _indexGroup;
			private static LocalPlayer Me { get { return ObjectManager.Me; } }

			public static int Spec
			{
				get
				{
					LoadCurrentSpec();

					int nSpec = 0;
					if (TabPoints[1] == 0 && TabPoints[2] == 0 && TabPoints[3] == 0)
					{
						if (Me.Level > 9)
						{ Logging.Write(Color.White, "*** NO TALENT POINTS HAVE BEEN SPENT YET ***"); }
						else if (Me.Level < 10)
						{ Logging.Write(Color.White, "*** Below level 10 no talent points available ***"); }
						nSpec = 0;
						return nSpec;
					}

					if (TabPoints[1] >= (TabPoints[2] + TabPoints[3])) nSpec = 1;
					else if (TabPoints[2] >= (TabPoints[1] + TabPoints[3])) nSpec = 2;
					else if (TabPoints[3] >= (TabPoints[1] + TabPoints[2])) nSpec = 3;

					return nSpec;
				}
			}

			public static void Load(int nGroup)
			{
				int nTab;
				_indexGroup = nGroup;


				for (nTab = 1; nTab <= 3; nTab++)
				{
					try
					{
						string luaCode = String.Format("return GetTalentTabInfo({0},false,false,{1})", nTab, _indexGroup);
						List<string> tabInfo = Lua.GetReturnValues(luaCode, "stuff.lua");

						TabNames[nTab] = tabInfo[1];
						TabPoints[nTab] = Convert.ToInt32(tabInfo[4]);
					}
					catch (Exception ex) { Logging.WriteException(ex); }
				}

			}

	        private static int ActiveGroup { get { return Lua.GetReturnVal<int>("return GetActiveTalentGroup(false,false)", 0); } }

		}
		#endregion

        #region Initialize
        public override void Initialize()
        {
			ClassSpec = (ClassType)Talents.Spec;
            Logging.Write(Color.White, "___________________________________________________");
            Logging.Write(Color.Crimson, "-------- Raid Master Rogue by NopiSoul --------");
            Logging.Write(Color.Crimson, "-----  Remember to comment on the forum! --");
            Logging.Write(Color.Crimson, "-------- /like and +rep if you like this CC! ------");
            Logging.Write(Color.White, "___________________________________________________");
			Logging.Write(Color.Crimson, string.Format("-----  You are a level {0} {1} {2} -----", Me.Level, ClassSpec, Me.Class));
            Logging.Write(Color.White, "___________________________________________________");
        }
        #endregion

        #region Settings

        public override bool WantButton
        {
            get
            {
                return true;
            }
        }

        public override void OnButtonPress()
        {

            RaidMasterRogue.RMRogueForm1 f1 = new RaidMasterRogue.RMRogueForm1();
            f1.ShowDialog();
        }
        #endregion

        #region Dragon Soul
        public bool Ultra()
        {
            using (new FrameLock())
            {
                if (RMRogueSettings.Instance.DSNOR || RMRogueSettings.Instance.DSHC || RMRogueSettings.Instance.DSLFR)
                {
                    foreach (WoWUnit u in ObjectManager.GetObjectsOfType<WoWUnit>(true, true))
                    {
                        if (u.IsAlive
                            && u.Guid != Me.Guid
                            && u.IsHostile
                            && u.IsCasting
                            && u.CastingSpell.Name == "Hour of Twilight"
                            && u.CurrentCastTimeLeft.TotalMilliseconds <= 1300)
                            return true;
                    }

                }

            }
            return false;
        }
        public bool UltraFL()
        {
            using (new FrameLock())
            {
                if (RMRogueSettings.Instance.DSNOR || RMRogueSettings.Instance.DSHC)
                {
                    foreach (WoWUnit u in ObjectManager.GetObjectsOfType<LocalPlayer>(true, true))
                    {
                        if (u.Debuffs.ContainsKey("Fading Light")
                            && u.Debuffs["Fading Light"].IsActive
                            && u.Debuffs["Fading Light"].TimeLeft.TotalMilliseconds <= 2000)
                            return true;
                    }

                }

            }
            return false;
        }
        public bool DW()
        {
            using (new FrameLock())
            {
                if (RMRogueSettings.Instance.DSNOR || RMRogueSettings.Instance.DSHC || RMRogueSettings.Instance.DSLFR)
                {
                    foreach (WoWUnit u in ObjectManager.GetObjectsOfType<WoWUnit>(true, true))
                    {
                        if (u.IsAlive
                            && u.Guid != Me.Guid
                            && u.IsHostile
                            && (u.IsTargetingMyPartyMember || u.IsTargetingMyRaidMember || u.IsTargetingMeOrPet || u.IsTargetingAnyMinion)
                            && u.IsCasting
                            && u.CastingSpell.Name == "Shrapnel"
                            && u.CurrentCastTimeLeft.TotalMilliseconds <= 1000)
                            return true;
                    }

                }

            }
            return false;
        }
        #endregion

        #region Add Detection
        private int addCount()
        {
            int count = 0;
            foreach (WoWUnit u in ObjectManager.GetObjectsOfType<WoWUnit>(true, true))
            {
                if (u.IsAlive
                    && u.Guid != Me.Guid
                    && u.IsHostile
                    && !u.IsCritter
                    && (u.Location.Distance(Me.CurrentTarget.Location) <= 12 || u.Location.Distance2D(Me.CurrentTarget.Location) <= 12)
                    && (u.IsTargetingMyPartyMember || u.IsTargetingMyRaidMember || u.IsTargetingMeOrPet || u.IsTargetingAnyMinion)
                    && !u.IsFriendly)
                {
                    count++;
                }
            }
            return count;
        }
        private bool IsTargetBoss()
        {
            using (new FrameLock())
            {
                if (Me.CurrentTarget.CreatureRank == WoWUnitClassificationType.WorldBoss ||
                (Me.CurrentTarget.Level >= 85 && Me.CurrentTarget.Elite) && Me.CurrentTarget.MaxHealth > 3500000)
                    return true;

                else return false;
            }
        }
        #endregion

        #region CastSpell Method
        // Credit to Apoc for the below CastSpell code
        // Used for calling CastSpell in the Combat Rotation
        //Credit to Wulf!
        public bool CastSpell(string spellName)
        {
            using (new FrameLock())
            {
                if (SpellManager.CanCast(spellName))
                {
                    SpellManager.Cast(spellName);
                    // We managed to cast the spell, so return true, saying we were able to cast it.
                    return true;
                }
            }
            // Can't cast the spell right now, so return false.
            return false;
        }
		private bool BuffCast(string spell, WoWPlayer playerDD)
        {
            if (SpellManager.Cast(spell, playerDD))
            {
                lastPlayer = playerDD;
                return true;
            }
			enemy = Me.CurrentTarget;
            ReTarget(playerDD);
			if (CheckMe(playerDD))
			{
				if (CastSpell(spell))
				{
					lastPlayer = playerDD;
					ReTarget(enemy);
					return true;
				}
			}
			ReTarget(enemy);
            return false;
        }
		public static bool IsOnCooldown(string spellName)
        {
            bool result = SpellManager.Spells[spellName].Cooldown;
            return result;
        }
        #endregion

		#region UseItem
		public static class HealthPotions
        {
            /// <summary>
            /// WoWItem type of a suitable Healing Potion in your bags. Null if nothing is found
            /// </summary>
            private static WoWItem HealthPotion
            {
                get { return Me.CarriedItems.Where(item => item.Name.Contains("Healing Pot")).FirstOrDefault(); }
            }

            /// <summary>
            /// Checks if this item is not on cooldown and can be used. Returns TRUE is the item is ok to be used
            /// </summary>
            public static bool IsUseable
            {
                get
                {
                    if (HealthPotion == null) return false;

                    //string luacode = String.Format("return GetItemCooldown(\"{0}\")", HealthPotion.Entry);
                    return (HealthPotion.Entry < 1);

                }
            }

            public static void Use()
            {
                //Utils.LagSleep();

                WoWItem healthPotion = HealthPotion;
                Logging.Write(Color.Red, string.Format("We're having an 'Oh Shit' moment. Using {0}", healthPotion.Name));
                HealthPotion.Interact();
            }

        }
		
		#endregion

        #region MyDebuffTime
        //Used for checking how the time left on "my" debuff
        private int MyDebuffTime(String spellName, WoWUnit unit)
        {
            using (new FrameLock())
            {
                if (unit.HasAura(spellName))
                {
                    var auras = unit.GetAllAuras();
                    foreach (var a in auras)
                    {
                        if (a.Name == spellName && a.CreatorGuid == Me.Guid)
                        {
                            return a.TimeLeft.Seconds;
                        }
                    }
                }
            }
            return 0;
        }
        #endregion

        #region DebuffTime
        //Used for checking debuff timers
        private int DebuffTime(String spellName, WoWUnit unit)
        {
            using (new FrameLock())
            {
                if (unit.HasAura(spellName))
                {
                    var auras = unit.GetAllAuras();
                    foreach (var b in auras)
                    {
                        if (b.Name == spellName)
                        {
                            return b.TimeLeft.Seconds;
                        }
                    }
                }
            }
            return 0;
        }
        #endregion

        #region IsMyAuraActive
        //Used for checking auras that has no time
        private bool IsMyAuraActive(WoWUnit Who, String What)
        {
            using (new FrameLock())
            {
                return Who.GetAllAuras().Where(p => p.CreatorGuid == Me.Guid && p.Name == What).FirstOrDefault() != null;
            }
        }
        #endregion

        #region CombatStart


        private void AutoAttack()
        {
            if (!Me.IsAutoAttacking && Me.CurrentTarget.Distance <= 7d)
            {
                Lua.DoString("StartAttack()");
            }
        }

		private void StopAttack()
        {
            if (Me.ActiveAuras.ContainsKey("Vanish"))
            {
                Lua.DoString("StopAttack()");
            }
        }
        #endregion

		#region Pulse

		public override void Pulse()
        {
            if (Me.IsValid && StyxWoW.IsInGame) {
                Combat();
            }
        }

		#endregion

        #region Combat

        public override void Combat()
        {
            if (Me.CurrentTarget != null && Me.CurrentTarget.IsAlive && !Me.Mounted)
            {
                ///////////////////////////////////////////////Randoms////////////////////////////////////////////////////////////////////////////////////////////////
                {
                    if (Ultra())
                    {
                        Lua.DoString("RunMacroText('/click ExtraActionButton1');");
                        {
                            Logging.Write(Color.Aqua, ">> Heroic Will! <<");
                        }
                    }
                }
                {
                    if (UltraFL())
                    {
                        Lua.DoString("RunMacroText('/click ExtraActionButton1');");
                        {
                            Logging.Write(Color.Aqua, ">> Heroic Will! <<");
                        }
                    }
                }
                {
                    if (DW())
                    {
                        Lua.DoString("RunMacroText('/click ExtraActionButton1');");
                        {
                            Logging.Write(Color.Aqua, ">> Enter the dream! <<");
                        }
                    }
                }

				/////////////////////////////////////////////Thread Situations and other///////////////////////////////////////////////////////////////////////////////////

				{
					if (Me.HealthPercent < 10)
                    {
                        if (HealthPotions.IsUseable)
                        {
                            HealthPotions.Use();
                        }
                    }
                    if (Me.CurrentTarget.ThreatInfo.RawPercent >= 90)
                    {
                        if (CastSpell("Feint"))
                        {
                            Logging.Write(Color.Crimson, ">>>> Feint <<<<");
                        }
                    }
					if (Me.CurrentTarget.ThreatInfo.RawPercent >= 100)
                    {
                        if (CastSpell("Vanish"))
                        {
                            StopAttack();
							Logging.Write(Color.Crimson, ">>>> Vanish <<<<");
                        }
                    }
					if (MyDebuffTime("Tricks of the Trade", Me) < 1 && !IsOnCooldown("Tricks of the Trade"))
					{
						SelectPlayer();
						if (BuffCast("Tricks of the Trade", playerDD))
						{
							Logging.Write(Color.White, ">> Trick of the Trade <<");
						}
					}
                }
				
                
                /////////////////////////////////////////////Out of Range rotation here//////////////////////////////////////////////////////////////////////////////////////

                {
                    if (RMRogueSettings.Instance.CHRG && Me.CurrentTarget.Distance >= 10d && Me.CurrentTarget.Distance <= 25d && (Talents.Spec == 3))
                    {
                        if (CastSpell("Shadowstep"))
                        {
                            Logging.Write(Color.Crimson, ">> Shadowstep <<");
                        }
                    }
                }
            }

                /////////////////////////////////////////////AoE Rotation here/////////////////////////////////////////////////////////////////////////////////////////////////

			if (Me.CurrentTarget.Distance <= 8d && Me.CurrentTarget.IsAlive && !Me.Mounted && RMRogueSettings.Instance.AOE && (Talents.Spec == 3))
            {
				
                    if (RMRogueSettings.Instance.BS && addCount() >= RMRogueSettings.Instance.Mobs && !Me.ActiveAuras.ContainsKey("Stealth") && !Me.Auras.ContainsKey("Shadow Dance") && !Me.Auras.ContainsKey("Vanish"))
                    {
                        if (CastSpell("Fan of Knives"))
                        {
                            Logging.Write(Color.Aqua, ">> Fan of Knives <<");
                        }
                    }
				
            }
			if (Me.CurrentTarget.Distance <= 10d && Me.CurrentTarget.IsAlive && !Me.Mounted && RMRogueSettings.Instance.AOE && (Talents.Spec == 2))
            {
				
                    if (RMRogueSettings.Instance.BS && addCount() >= RMRogueSettings.Instance.Mobs && !Me.ActiveAuras.ContainsKey("Stealth") && !Me.Auras.ContainsKey("Shadow Dance") && !Me.Auras.ContainsKey("Vanish"))
                    {
                        if (CastSpell("Fan of Knives"))
                        {
                            Logging.Write(Color.Aqua, ">> Fan of Knives <<");
                        }
                    }

            }
			if (Me.CurrentTarget.Distance <= 5d && Me.CurrentTarget.IsAlive && !Me.Mounted && RMRogueSettings.Instance.AOE && (Talents.Spec == 2))
            {
				{
					if (!Me.ActiveAuras.ContainsKey("Blade Flurry") && (addCount() > 1 && !Me.ActiveAuras.ContainsKey("Stealth") && !Me.Auras.ContainsKey("Vanish")))
                    {
                        if (CastSpell("Blade Flurry"))
                        {
                            Logging.Write(Color.Aqua, ">> Blade Flurry - Aktivated <<");
                        }
                    }
					if (addCount() < 2 && Me.ActiveAuras.ContainsKey("Blade Flurry"))
                    {
                        if (CastSpell("Blade Flurry"))
                        {
                            Logging.Write(Color.Aqua, ">> Blade Flurry - Deaktivated<<");
                        }
                    }
				}
			}

                /////////////////////////////////////////////Cooldowns are here////////////////////////////////////////////////////////////////////////////////////////////////

            if (Me.CurrentTarget != null && Me.CurrentTarget.IsAlive && !Me.Mounted)
            {
                {
                    if (RMRogueSettings.Instance.T1 && IsTargetBoss() && StyxWoW.Me.Inventory.Equipped.Trinket1 != null && StyxWoW.Me.Inventory.Equipped.Trinket1.Cooldown <= 0)
                        Lua.DoString("RunMacroText('/use 13');");
                }
                {
                    if (RMRogueSettings.Instance.T2 && IsTargetBoss() && StyxWoW.Me.Inventory.Equipped.Trinket2 != null && StyxWoW.Me.Inventory.Equipped.Trinket2.Cooldown <= 0)
                        Lua.DoString("RunMacroText('/use 14');");
                }
                {
                    if (IsTargetBoss())
                        Lua.DoString("RunMacroText('/use 10');");
                }

                    //////////////////////////////////////////////////Racial Skills here/////////////////////////////////////////////////////////////////////////////////////////

                {
                    if (IsTargetBoss() && Me.Race == WoWRace.Troll && IsTargetBoss())
                        Lua.DoString("RunMacroText('/Cast Berserking');");
                }
                {
                    if (IsTargetBoss() && Me.Race == WoWRace.Orc && IsTargetBoss())
                        Lua.DoString("RunMacroText('/Cast Blood Fury');");
                }
				{
                    if (IsTargetBoss() && Me.Race == WoWRace.BloodElf && IsTargetBoss() && Me.CurrentEnergy < 15)
                        Lua.DoString("RunMacroText('/Cast Arcane Torrent');");
                }
            }

            /////////////////////////////////////////////////Single Target DPS Subtlety////////////////////////////////////////////////////////////////////////////////////////////

				//1) Ambush (if CP < 4)
				//2) Slice and Dice is maintained (at 5 CP)
				//3) Rupture DOT maintained (at 5 CP)
				//4) Recuperate (at 5 CP)
				//5) Eviscerate (at 5 CP)
				//6) Hemorrhage to maintain bleed debuff
				//7) Backstab to generate combo points

            if (Me.CurrentTarget != null && Me.CurrentTarget.IsAlive && !Me.Mounted && (addCount() < RMRogueSettings.Instance.Mobs) && (Talents.Spec == 3))
            {

                ////// Interrupts //////
                //if (Me.CurrentTarget.IsCasting && Me.CanInterruptCurrentSpellCast)
                //{
                //    if (CastSpell("Kick"))
                //        Logging.Write(Color.FloralWhite, ">> Stop casting you bitch! <<");
                //}

                if (Me.ActiveAuras.ContainsKey("Stealth"))
                {
                    if(CastSpell("Ambush"))
                    {
                        Logging.Write(Color.Aqua, ">> Ambush <<");
                    }
                }
				if (Me.ActiveAuras.ContainsKey("Shadow Dance") && Me.ComboPoints < 4)
                {
                    if(CastSpell("Premeditation"))
                    {
                        Logging.Write(Color.White, ">> Premeditation <<");
                    }
                }
				if (Me.ActiveAuras.ContainsKey("Shadow Dance"))
                {
                    if(CastSpell("Ambush"))
                    {
                        Logging.Write(Color.Aqua, ">> Ambush <<");
                    }
                }
				if (!Me.ActiveAuras.ContainsKey("Shadow Dance") && Me.ComboPoints < 2 && MyDebuffTime("Recuperate", Me) > 15 && Me.CurrentEnergy < 40)
                {
                    if(CastSpell("Shadow Dance"))
                    {
                        Logging.Write(Color.Red, ">> Shadow Dance <<");
                    }
                }
				if (MyDebuffTime("Recuperate", Me) < 8 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Recuperate"))
                    {
                        Logging.Write(Color.White, ">> Recuperate <<");
                    }
                }
				if (MyDebuffTime("Rupture", Me.CurrentTarget) < 1 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Rupture"))
                    {
                        Logging.Write(Color.Aqua, ">> Rupture <<");
                    }
                }
				if (MyDebuffTime("Slice and Dice", Me) < 5 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Slice and Dice"))
                    {
                        Logging.Write(Color.White, ">> Slice and Dice <<");
                    }
                }
				if (MyDebuffTime("Rupture", Me.CurrentTarget) >= 1 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Eviscerate"))
                    {
                        Logging.Write(Color.Yellow, ">> Eviscerate <<");
                    }
                }
				if (MyDebuffTime("Hemorrhage", Me.CurrentTarget) < 3)
                {
                    if (CastSpell("Hemorrhage"))
                    {
                        Logging.Write(Color.Blue, ">> Hemorrhage <<");
                    }
                }
				if (Me.ComboPoints < 5 && Me.CurrentEnergy > 39)
                {
                    if (CastSpell("Backstab"))
                    {
                        Logging.Write(Color.Blue, ">> Backstab <<");
                    }
                }

            }
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

			/////////////////////////////////////////////////Single Target DPS Combat Rogue////////////////////////////////////////////////////////////////////////////////////////////

				//1) Slice and Dice is kept up if it's about to fall off no matter what
				//2) Revealing Strike at 4 CP right before Rupture or Eviscerate
				//3) Rupture DOT maintained (at 5 CP)
				//4) Eviscerate (at 5 CP)
				//5) Sinister Strike to generate CP

            if (Me.CurrentTarget != null && Me.CurrentTarget.IsAlive && !Me.Mounted && (addCount() < RMRogueSettings.Instance.Mobs) && (Talents.Spec == 2))
            {
				/*
                ////// Interrupts //////
                if (Me.CurrentTarget.IsCasting && Me.CanInterruptCurrentSpellCast)
                {
                    if (CastSpell("Fan of Knives"))
                        Logging.Write(Color.FloralWhite, ">> Stop casting you bitch! <<");
                }
				*/
				if (Me.ActiveAuras.ContainsKey("Stealth"))
                {
                    if(CastSpell("Ambush"))
                    {
                        Logging.Write(Color.Aqua, ">> Ambush <<");
                    }
                }

				if (Me.CurrentEnergy < 30 && !Me.ActiveAuras.ContainsKey("Stealth") && !Me.Auras.ContainsKey("Vanish"))
                {
                    if(CastSpell("Adrenaline Rush"))
                    {
                        Logging.Write(Color.White, ">> Adrenaline Rush <<");
                    }
                }

                if (MyDebuffTime("Slice and Dice", Me) > 15 && MyDebuffTime("Rupture", Me.CurrentTarget) < 10 && !Me.ActiveAuras.ContainsKey("Stealth") && !Me.Auras.ContainsKey("Vanish"))
                {
                    if(CastSpell("Killing Spree"))
                    {
                        Logging.Write(Color.Red, ">> Killing Spree <<");
                    }
                }

				if (MyDebuffTime("Slice and Dice", Me) < 5 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Slice and Dice"))
                    {
                        Logging.Write(Color.White, ">> Slice and Dice <<");
                    }
                }
				if (MyDebuffTime("Rupture", Me.CurrentTarget) < 1 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Rupture"))
                    {
                        Logging.Write(Color.Aqua, ">> Rupture <<");
                    }
                }
				if (MyDebuffTime("Rupture", Me.CurrentTarget) >= 1 && Me.ComboPoints > 4)
                {
                    if (CastSpell("Eviscerate"))
                    {
                        Logging.Write(Color.Yellow, ">> Eviscerate <<");
                    }
                }
				if (Me.ComboPoints >= 4 && MyDebuffTime("Slice and Dice", Me) > 5)
                {
                    if (CastSpell("Revealing Strike"))
                    {
                        Logging.Write(Color.Blue, ">> Revealing Strike <<");
                    }
                }
				if ((MyDebuffTime("Slice and Dice", Me) > 5 && Me.ComboPoints <= 3 && Me.CurrentEnergy > 33) || (MyDebuffTime("Slice and Dice", Me) <= 5 && Me.ComboPoints <= 4 && Me.CurrentEnergy > 33))
                {
                    if (CastSpell("Sinister Strike"))
                    {
                        Logging.Write(Color.Aqua, ">> Sinister Strike <<");
                    }
                }
            }                
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        }

        #endregion

    }
}